//
//  ViewController.m
//  RuntimeArchiver
//
//  Created by QC.L on 16/4/6.
//  Copyright © 2016年 QC.L. All rights reserved.
//

#import "ViewController.h"
#import "QCRootClass.h"

@interface ViewController ()
@property (nonatomic, strong) QCRootClass *qcClass;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    
    [self handleData];
//    
//    
//    // 归档
    [NSKeyedArchiver archiveRootObject:self.qcClass toFile:[NSHomeDirectory() stringByAppendingPathComponent:@"xxx.a"]];
    
    NSLog(@"%@", self.qcClass.abstract);
    
    self.qcClass = [NSKeyedUnarchiver unarchiveObjectWithFile:[NSHomeDirectory() stringByAppendingPathComponent:@"xxx.a"]];
    NSLog(@"%@", self.qcClass.abstract);
    
}

- (void)handleData {
    
    NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"File"  ofType:@"json"]];
    
    id result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
    self.qcClass = [[QCRootClass alloc] init];
    [self.qcClass setValuesForKeysWithDictionary:result];
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
